#include "swpgeneralizationgraphicitem.h"

#include "graphicitemcommon.h"

#include <pathgraphicitem.h>

using namespace core;
using namespace swp;

SwpGeneralizationGraphicItem::SwpGeneralizationGraphicItem(
    QGraphicsItem* parent) : AbstractLineGraphicItem(
        QPointF(),
        QPointF(),
        QList<QPointF>(),
        parent)
{
    setFlags(flags() | QGraphicsItem::ItemIsSelectable);

    createArrows();

    updateLine();
}

SwpGeneralizationGraphicItem::SwpGeneralizationGraphicItem(
    const QPointF& startPoint,
    const QPointF& endPoint,
    const QList<QPointF>& anchors,
    QGraphicsItem* parent) : AbstractLineGraphicItem(
        startPoint,
        endPoint,
        anchors,
        parent)
{
    setFlags(flags() | QGraphicsItem::ItemIsSelectable);

    createArrows();

    updateLine();
}

SwpGeneralizationGraphicItem::~SwpGeneralizationGraphicItem()
{

}

int SwpGeneralizationGraphicItem::type() const
{
    return SWP_GENERALIZATION_ITEM;
}

QString SwpGeneralizationGraphicItem::name() const
{
    return QObject::tr("Generalization");
}

IEditorItem* SwpGeneralizationGraphicItem::copy() const
{
    return new SwpGeneralizationGraphicItem();
}

QList<Property> SwpGeneralizationGraphicItem::properties() const
{
    QList<Property> ret;

    return ret;
}

QVariant SwpGeneralizationGraphicItem::propertyValue(
    const QString& propertyName) const
{
    QVariant ret;

    return ret;
}

void SwpGeneralizationGraphicItem::propertyChanged(const QString& property,
    const QVariant& newValue, bool silent)
{

}

QVariantList SwpGeneralizationGraphicItem::optionList(
    const QString& propertyName) const
{
    QVariantList ret;

    return ret;
}

QVariantList SwpGeneralizationGraphicItem::autocomplete(
    const QString& propertyName) const
{
    QVariantList ret;

    return ret;
}

void SwpGeneralizationGraphicItem::createArrows()
{
    QPolygonF endArrow;
    endArrow << QPointF(-10, -8) << QPointF(10, 0) << QPointF(-10, 8) <<
        QPointF(-10, -8);

    QPainterPath _endArrow;
    _endArrow.addPolygon(endArrow);
    //_endArrow.closeSubpath();

    setEndArrow(new gui::PathGraphicItem(_endArrow));
}
